#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project: DataStructure-Python
@File: Deque.py
@Author: Dragon Geek
@Date: 2021/4/19 10:15
@Description: Bubble Sort Algorithm
"""


class Deque(object):
    # 初始化双端队列
    def __init__(self):
        self.__list = []

    # 从队列头部添加一个元素
    def add_front(self, item):
        self.__list.insert(0, item)

    # 从队列头部删除一个元素
    def pop_front(self):
        return self.__list.pop(0)

    # 从队列尾部添加一个元素
    def add_rear(self, item):
        self.__list.append(item)

    # 从队列尾部删除一个元素
    def pop_rear(self):
        return self.__list.pop()

    # 判断双端队列是否为空
    def is_empty(self):
        return self.__list == []

    # 返回队列的大小
    def size(self):
        return len(self.__list)


if __name__ == "__main__":
    Deque_01 = Deque()
    print(Deque_01.is_empty())
    print(Deque_01.size())
    Deque_01.add_front(1)
    Deque_01.add_front(2)
    Deque_01.add_rear(3)
    Deque_01.add_rear(4)
    print(Deque_01.size())
    print(Deque_01.pop_front())
    print(Deque_01.pop_rear())
    print(Deque_01.size())